<?php
namespace Modules\Buy\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\Buy\Entities\Adress;
use Modules\Buy\Entities\Dingdan;
use Modules\Buy\Entities\Order;
use Modules\Buy\Entities\Orderlist;
use Modules\Buy\Http\Requests\DingdanRequest;
class DingdanController extends Controller
{
    //显示列表
    public function index()
    {
//        $data = Dingdan::paginate(10);
        $data = Order::paginate(10);
//        dd($data->toArray());
        return view('buy::dingdan.index', compact('data'));
    }
    
//    加载订单详情页面
    public function more($orderId)
    {

//        dd($orderId);
        $order = Order::where('orderId',$orderId)->first();
//        dd($order->toArray());
        $orderlist = Orderlist::where('orderId',$orderId)->get();
//        dd($orderlist->toArray());
        $adress = Adress::where('status',1)->first();
//        dd($adress->toArray());
        return view('buy::dingdan.more',compact('order','adress','orderlist'));

    }

//    订单状态变为2
    public function fahuo($orderId)
    {
//        return 123;
//        dd($orderId);
//        找到对应的订单，把状态变为2
        Order::where('orderId',$orderId)->update([
           'status'=>2
        ]);

        return ['volid'=>1,'message'=>'更新成功'];
    }
}
